<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); ?>
<style>
<!--
	#show-content-body #header{
		background:url('<?php echo site_url();?>addons/themes/ranking/css/images/header_contact_bg.png') no-repeat scroll center top transparent;
	}
	#contact-form{
		margin-left:20px;
		width:800px;
	}
	#form-wrap{
		width:800px;
		float:left;
		border:1px solid #4e4e4e;
		min-height:475px;
		margin-top:20px;
	}
	#form-wrap dl{
		float:left;
		width:100%;
		border-bottom:1px solid #4e4e4e;
	}
	#form-wrap dl dt{
		float:left;
		width:225px;
		background:#0c0c0c;
		color:#fff;
		padding:10px 0px 10px 30px;
	}
	#form-wrap dl dd{
		float:left;
		width:545px;
	}
	.red-text{color:red;}

	.input-type{border:1px solid #4e4e4e;width:488px;height:25px;float:left;margin-left:27px;margin-top: 8px;background:#f4f4f4;}
-->
</style>
<div class="wrap-content border">
	<section id="show-content-body">
		<div id="header"></div>
		<div class="clrboth"></div>

		<div id="wrap-body">
			<div id="wrap">
				<div id="header-title">
					<h2><?php echo lang('contact.form.title');?></h2>
					<h3><?php echo lang('contact.form.title2');?></h3>
				</div>
				<div class="clrboth"></div>

				<div id="contact-form">
				<?php echo form_open('contact','id="contact_form" name="contact_form"');?>
					<span><?php echo lang('contact.form.title3');?></span>
					<div class="clrboth"></div>

					<div id="form-wrap">
						<dl>
							<dt><?php echo lang('contact.form.name');?></dt>
							<dd><input type="text" name="name_field" id="name_field" maxlength="55" class="input-type" /></dd>
						</dl>
						<div class="clrboth"></div>
						<dl>
							<dt><?php echo lang('contact.form.email');?></dt>
							<dd><input type="text" name="email_field" id="email_field" maxlength="55" class="input-type" /></dd>
						</dl>
						<div class="clrboth"></div>
						<dl>
							<dt><?php echo lang('contact.form.email2');?></dt>
							<dd><input type="text" name="email_field2" id="email_field2" maxlength="55" class="input-type" /></dd>
						</dl>
						<div class="clrboth"></div>
						<dl>
							<dt style="height:100px;"><?php echo lang('contact.form.fields');?></dt>
							<dd>
								<table style="padding-left:20px;">
									<tr>
										<td><input type="checkbox" id="aaa" name="aaa" value="<?php echo lang('contact.form.AAA');?>" />&nbsp;<?php echo lang('contact.form.AAA');?></td>
										<td><input type="checkbox" id="bbb" name="bbb" value="<?php echo lang('contact.form.BBB');?>" />&nbsp;<?php echo lang('contact.form.BBB');?></td>
									</tr>
									<tr>
										<td><input type="checkbox" id="ccc" name="ccc" value="<?php echo lang('contact.form.CCC');?>" />&nbsp;<?php echo lang('contact.form.CCC');?></td>
										<td><input type="checkbox" id="ddd" name="ddd" value="<?php echo lang('contact.form.DDD');?>" />&nbsp;<?php echo lang('contact.form.DDD');?></td>
									</tr>
									<tr>
										<td><input type="checkbox" id="eee" name="eee" value="<?php echo lang('contact.form.EEE');?>" />&nbsp;<?php echo lang('contact.form.EEE');?></td>
										<td><input type="checkbox" id="fff" name="fff" value="<?php echo lang('contact.form.FFF');?>" />&nbsp;<?php echo lang('contact.form.FFF');?></td>
									</tr>
								</table>
							</dd>
						</dl>
						<div class="clrboth"></div>
						<dl style="border-bottom:0 none;">
							<dt style="height:200px;"><?php echo lang('contact.form.inquiry');?></dt>
							<dd><textarea class="input-type" style="height:200px;" id="inquiry" name="inquiry" cols="35" rows="5"></textarea></dd>
						</dl>
					</div>
				<?php echo form_close();?>
				</div>

				<div class="clrboth"></div>
				 <div class="wrap-button" style="height:135px;color:#fff;">
				 	<p>&nbsp;</p>
				 	<?php echo lang('contact.form.title4');?>
				 	<div class="clrboth"></div>

					<div id="second_gray_button" onclick="window.location='<?php echo site_url();?>'">キャンセル</div>
					<div id="second_OK_button" onclick="send_contact();">OK</div>
				</div>
			</div>
		</div>
	</section>
</div>

<div id="report_violate_msg" class="hidden"></div>

<script type="text/javascript">
	function send_contact(){
		obj = eval( jQuery('#contact_form').serializeArray() );
		json = {};
		for (i in obj ) {
		    json[obj[i].name] = obj[i].value
		}

		var err= 0;
		if( isEmpty(json.name_field) ){
			err++;
			$('#name_field').addClass('error');
		}else{
			$('#name_field').removeClass('error');
		}

		if( isEmpty(json.email_field) || !isEmail(json.email_field) ){
			err++;
			$('#email_field').addClass('error');
		}else{
			$('#email_field').removeClass('error');
		}

		if( isEmpty(json.email_field2) || !isEmail(json.email_field2) || json.email_field2 != json.email_field ){
			err++;
			$('#email_field2').addClass('error');
		}else{
			$('#email_field2').removeClass('error');
		}

		if( err >0 ){self.scrollTo(0,0);return false;}

		$.post(BASE_URI+'content/contact_send',{data:obj},function(res){
			$('#contact_form')[0].reset();
			$('#report_violate_msg').html(res);
			$('#report_violate_msg').dialog(
				{
					dialogClass: 'rank_alert',
					 buttons: [
					           {
					               text: "OK",
					               click: function() { $(this).dialog("close"); }
					           }
				           ]
				}
			);
		});
	}
</script>